/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* IBust - IBus with Traditional interface
 * Copyright(c) 2013 Daniel Sun
 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
 * Copyright (C) 2008-2010 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined (__IBUST_H_INSIDE__) && !defined (IBUST_COMPILATION)
#error "Only <ibust.h> can be included directly"
#endif

/**
 * SECTION: ibustproplist
 * @Title: IBustPropList
 * @Short_description: An #IBustProperty container.
 * @Stability: Stable
 *
 * @See_also: #IBustProperty, #IBustEngine
 *
 */
#ifndef __IBUST_PROP_LIST_H_
#define __IBUST_PROP_LIST_H_

#include "ibustserializable.h"
#include "ibustproperty.h"

G_BEGIN_DECLS

/*
 * Type macros.
 */
/* define IBustPropList macros */
#define IBUST_TYPE_PROP_LIST             \
    (ibust_prop_list_get_type ())
#define IBUST_PROP_LIST(obj)             \
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUST_TYPE_PROP_LIST, IBustPropList))
#define IBUST_PROP_LIST_CLASS(klass)     \
    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUST_TYPE_PROP_LIST, IBustPropListClass))
#define IBUST_IS_PROP_LIST(obj)          \
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUST_TYPE_PROP_LIST))
#define IBUST_IS_PROP_LIST_CLASS(klass)  \
    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUST_TYPE_PROP_LIST))
#define IBUST_PROP_LIST_GET_CLASS(obj)   \
    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUST_TYPE_PROP_LIST, IBustPropListClass))

#ifndef __PROPLIST_DEFINED
#define __PROPLIST_DEFINED
typedef struct _IBustPropList IBustPropList;
typedef struct _IBustPropListClass IBustPropListClass;
#endif

/**
 * IBustPropList:
 * @properties: GArray that holds IBustProperties.
 *
 * An array of IBustProperties.
 */
struct _IBustPropList {
    IBustSerializable parent;

    /*< public >*/
    GArray *properties;
};

struct _IBustPropListClass {
    IBustSerializableClass parent;
};

GType            ibust_prop_list_get_type    ();

/**
 * ibust_prop_list_new:
 * @returns: A newly allocated IBustPropList.
 *
 * New a IBustPropList.
 */
IBustPropList    *ibust_prop_list_new         ();

/**
 * ibust_prop_list_append:
 * @prop_list: An IBustPropList.
 * @prop: IBustProperty to be append to @prop_list.
 *
 * Append an IBustProperty to an IBustPropList, and increase reference.
 */
void             ibust_prop_list_append      (IBustPropList   *prop_list,
                                             IBustProperty   *prop);

/**
 * ibust_prop_list_get:
 * @prop_list: An IBustPropList.
 * @index: Index of an IBustPropList.
 * @returns: (transfer none): IBustProperty at given index, NULL if no such IBustProperty.
 *
 * Returns IBustProperty at given index. Borrowed reference.
 */
IBustProperty    *ibust_prop_list_get         (IBustPropList   *prop_list,
                                             guint           index);

/**
 * ibust_prop_list_update_property:
 * @prop_list: An IBustPropList.
 * @prop: IBustProperty to be update.
 * @returns: TRUE if succeeded, FALSE otherwise.
 *
 * Update an IBustProperty in IBustPropList.
 */
gboolean         ibust_prop_list_update_property
                                            (IBustPropList   *prop_list,
                                             IBustProperty   *prop);
G_END_DECLS
#endif
